<?php
namespace app\index\service;

use app\index\model\SubbaoJieModel;
use app\index\model\SubbaoShenModel;

class SubbaoService extends CommonService
{

    public function create_subbao_shen_number(){
        $tou = 'JDKSB';
        $daystr = substr(date("Ymd"), 2);
        $number = SubbaoShenModel::where('number','like','%'.$tou.$daystr.'%')->order('number DESC')->value('number');
        if(!$number){
            $str = $tou.$daystr.'00001';
        }else{
            $str = $tou.((int)str_replace($tou,'',$number)+1);
        }
        return $str;
    }

    public function create_subbao_jie_number(){
        $tou = 'WGJS';
        $daystr = substr(date("Ymd"), 2);
        $number = SubbaoJieModel::where('number','like','%'.$tou.$daystr.'%')->order('number DESC')->value('number');
        if(!$number){
            $str = $tou.$daystr.'00001';
        }else{
            $str = $tou.((int)str_replace($tou,'',$number)+1);
        }
        return $str;
    }

}
